package com.wmyg.antifake.sdk;

import com.alibaba.fastjson.JSON;
import com.wmyg.antifake.bean.QRInfo;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Map;

public class SDKsouthtest {

    @Test
    public void firstInstallTest() throws Throwable {
        SmartManager smartManager = ManageBuilder.buildManagerToInstall("south", "Admin", "antifake", "developchannel");
        smartManager.firstInstall(new String[]{""});
    }

    @Test
    public void installTest() throws Throwable {
        SmartManager smartManager = ManageBuilder.buildManagerToInstall("south", "Admin", "antifake", "developchannel");
        smartManager.install(new String[]{"init","1"});
    }

    @Test
    public void invokeTest() throws Throwable {
        ArrayList<String> items = new ArrayList<>();
        items.add("I1");
        items.add("I2");
        items.add("I3");
        String list = JSON.toJSONString(items);
        System.out.println(list);
        String[] args = new String[]{"(01)06933684005129(10)J9RZD1(21)X1812297TVRUX1DD", "beijing", "2018-01-01 00:00:00",
                "Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; MB200 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
        "0", "0", "0.0.0.1", "0"};
        SmartManager smartManager = ManageBuilder.buildManagerToUse("south", "User1", "antifake", "developchannel");
        Map<String, String> map = smartManager.invoke("queryQRInfo", args);
//        if ("success".equals(map.get("code"))) {
//            QRInfo qrInfo = JSON.parseObject(map.get("data"), QRInfo.class);
//            System.out.println(qrInfo.getQueryHistory().size());
//        }
        System.out.println(map);
        smartManager.shutdown();
        Map<String, String> map2 = smartManager.invoke("queryQRInfo", args);
        System.out.println(map2);
    }

    @Test
    public void queryTest() throws Throwable {
        SmartManager smartManager = ManageBuilder.buildManagerToUse("south", "User1", "antifake", "developchannel");
        System.out.println(smartManager.query("queryCar", new String[]{"(01)06933684005129(10)TUS951(21)H181112WBWRLDFYQ"}));
    }

}
